package sk.naive.talker;

import sk.naive.talker.persistence.*;
import sk.naive.talker.props.*;
import sk.naive.talker.util.PropertyConfiguration;

import java.util.*;

/**
 * Thing.
 *
 * @author <a href="mailto:sue@naive.deepblue.sk">Sue</a>
 * @version $Revision: 1.6 $ $Date: 2007-05-07 10:34:20 $
 */
public abstract class Thing implements PersistentObject {
	public static final String TPROP_NAME = "name";
	public static final String TPROP_TYPE = "type";

	private PersistentPropertyStoreImpl store;

	public Thing(Integer id, PropertyConfiguration propertyConfiguration) {
		store = new PersistentPropertyStoreImpl(id, propertyConfiguration);
	}

	public String getName() {
		return (String) get(TPROP_NAME);
	}

	public Integer getId() {
		return store.getId();
	}

	public void setStoredValue(String key, String value) throws PropertyStoreException {
		store.setStoredValue(key, value);
	}

	public Object get(String key) {
		return store.get(key);
	}

	public void set(String property, Object value) throws PropertyStoreException {
		store.set(property, value);
	}

	public Map<String,Object> getProperties() {
		return store.getProperties();
	}

	public Property getProperty(String key) {
		return store.getProperty(key);
	}

	public String getType() {
		return (String) get(TPROP_TYPE);
	}
}
